﻿using System;
using System.Collections.Generic;
using System.Text;

namespace HAVNet.Intros.AST
{
    //                                  (. smd = new ASTMemberDeclFixedBuffer(); .)
    //  "fixed"                         (. tsym (t, depth); .)
    //  Type<out type, true, out ty>                            (. ((ASTMemberDeclFixedBuffer)smd).type         = type; .)
    //  ident                           (. tsym (t, depth); .)  (. ((ASTMemberDeclFixedBuffer)smd).ident        = t.val;.)
    //  "["                             (. tsym (t, depth); .)
    //  Expression<out expr>                                    (. ((ASTMemberDeclFixedBuffer)smd).expression   = expr; .)
    //  "]"                             (. tsym (t, depth); .)
    //  ";"								(. tsym (t, depth); .)

    public class ASTMemberDeclFixedBuffer : ASTMemberDeclStruct
    {
        public ASTType          type        { get; set; }
        public string           ident       { get; set; }
        public ASTExpr    expression  { get; set; }

        public override string ToString ()
        {
            // new public private internal unsafe
            string mods = "";

            if (Mods.has(modifiers, Mods.newMod     )) mods += "new ";
            if (Mods.has(modifiers, Mods.publicMod  )) mods += "public ";
            if (Mods.has(modifiers, Mods.internalMod)) mods += "internal ";
            if (Mods.has(modifiers, Mods.privateMod )) mods += "private ";
            if (Mods.has(modifiers, Mods.unsafeMod  )) mods += "unsafe ";
            
            return mods + "fixed " + type.ToString() + " " + ident + " [" + expression.ToString() + "];";
        }
    }
}
